/**
 * 收费统计
 */
<template>
  <div>
 <h2>收费统计                                   
      <el-button type="primary" round @click="handleEdit" style="position:absolute;right:30px">返回</el-button>
      </h2>
   
    <!--列表-->
    <h3>处方明细</h3>
    <el-table
      size="small"
      :data="listData"
      highlight-current-row
      v-loading="loading"
      border
      element-loading-text="拼命加载中"
      style="width: 100%"
    >

      <el-table-column
        prop="quantity"
        label="药品数量"
        width="120"
        show-overflow-tooltip
        align="center"
      >
      </el-table-column>

      <el-table-column
        prop="unit"
        label="单位"
        width="150"
        show-overflow-tooltip
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop="commonName"
        label="药品名称"
        width="180"
        show-overflow-tooltip
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop="price"
        label="单价"
        width="100"
        show-overflow-tooltip
        align="center"
      >
      </el-table-column>
     

        


     
    </el-table>
<div>
  <!--列表-->
    <h3>订单信息</h3>
    <el-table
      size="small"
      :data="listData"
      highlight-current-row
      v-loading="loading"
      border
      element-loading-text="拼命加载中"
      style="width: 100%"
    >

      <el-table-column
        prop="rid"
        label="订单编号"
        width="120"
        show-overflow-tooltip
        align="center"
      >
      </el-table-column>

      <el-table-column
        prop="registrationFee"
        label="挂号费用"
        width="150"
        show-overflow-tooltip
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop="prescriptionFee"
        label="处方费"
        width="150"
        show-overflow-tooltip
        align="center"
      >
      <template slot-scope="scope">
      {{(listData[scope.$index].prescriptionFee)/100}}
      </template>
      </el-table-column>
      <el-table-column
        prop=""
        label="合计"
        width="130"
        show-overflow-tooltip
        align="center"
      >
      <template slot-scope="scope">
      {{listData[scope.$index].registrationFee+(listData[scope.$index].prescriptionFee)/100}}
      </template>
      </el-table-column>
</el-table>


  
</div>
<div>
  <!--列表-->
    <h3>人员信息</h3>
    <el-table
      size="small"
      :data="listData"
      highlight-current-row
      v-loading="loading"
      border
      element-loading-text="拼命加载中"
      style="width: 100%"
    >

      <el-table-column
        prop="pid"
        label="患者编号"
        width="120"
        show-overflow-tooltip
        align="center"
      >
      </el-table-column>

      <el-table-column
        prop="pname"
        label="患者姓名"
        width="100"
        show-overflow-tooltip
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop="page"
        label="年龄"
        width="90"
        show-overflow-tooltip
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop="psex"
        label="年龄"
        width="90"
        show-overflow-tooltip
        align="center"
      >
      </el-table-column>
       <el-table-column
        prop="phoneNumber"
        label="手机号"
        width="150"
        show-overflow-tooltip
        align="center"
      >
      </el-table-column>
</el-table>


  
</div>
<div>
  <!--列表-->
    <h3>接诊信息</h3>
    <el-table
      size="small"
      :data="listData"
      highlight-current-row
      v-loading="loading"
      border
      element-loading-text="拼命加载中"
      style="width: 100%"
    >

      <el-table-column
        prop="rid"
        label="门诊编号"
        width="120"
        show-overflow-tooltip
        align="center"
      >
      </el-table-column>

      <el-table-column
        prop="office"
        label="科室"
        width="150"
        show-overflow-tooltip
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop="doctorName"
        label="接诊医生"
        width="100"
        show-overflow-tooltip
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop="date"
        label="接诊日期"
        width="180"
        show-overflow-tooltip
        align="center"
      >
      </el-table-column>
      
</el-table>


  
</div>
  </div>

</template>

 





<script>
import axios from "axios";
import { ConfigList, ConfigSave, ConfigDelete } from "../../api/payMG";
import Pagination from "../../components/Pagination";
import { regionData,CodeToText,TextToCode} from 'element-china-area-data';
export default {
  data() {
    return {

      
      //查询后端数据存放的地方
      patient: {
        rid:"",
        keywords: "",
        startDate: "",
        endDate: "",
        pageNum: "",
        pageSize:""
      },

      loading: false, //是显示加载
      editFormVisible: false, //控制编辑页面显示与隐藏
      title: "添加",
      
      editForm: {
        id:"",
        name: "",
        idcard: "",
        age: "",
        birthday: "",
        sex: "",
        phoneNumber: "",
        address:"",
        myAddress:[],
        detailAddress:"",
        source: "",
        nation: "",
        maritalStatus: "",
        education: "",
        occupation: "",
        workPlace: "",
        mark:"",
        token: localStorage.getItem("logintoken"),
      },
      // rules表单验证
      rules: {
        name: [{ required: true, message: "请输入患者名称", trigger: "blur" }],
        idcard: [
          { required: true, message: "请输入患者身份证号码", trigger: "blur" },
        ],
        age: [{ required: true, message: "请输入患者年龄", trigger: "blur" }],
        // birthday: [
        //   { required: true, message: "请选择患者的出生年月", trigger: "blur" },
        // ],
        sex: [{ required: true, message: "请选择患者性别", trigger: "blur" }],
        phoneNumber: [
          { required: true, message: "请输入患者电话号码", trigger: "blur" },
        ],
        // source: [
        //   { required: true, message: "请选择患者来源", trigger: "blur" },
        // ],
        // address: [
        //   { required: true, message: "请选择地址", trigger: "blur" },
        // ],
        // detailAddress: [
        //   { required: true, message: "请输入详细地址", trigger: "blur" },
        // ],
        // nation: [
        //   { required: true, message: "请选择患者民族", trigger: "blur" },
        // ],
        // maritalStatus: [
        //   { required: true, message: "请选择患者婚姻状态", trigger: "blur" },
        // ],
        // education: [
        //   { required: true, message: "请选择患者文凭", trigger: "blur" },
        // ],
        // occupation: [
        //   { required: true, message: "请选择患者职业", trigger: "blur" },
        // ],
        // workPlace: [
        //   { required: true, message: "请输入患者工作地址", trigger: "blur" },
        // ],
      },
      formInline: {
        rid:1,
        page: 1,
        limit: 10,
        name: "",
        payType: 0,
        partner: "",
        token: localStorage.getItem("logintoken"),
      },
      // 删除部门
      seletedata: {
        ids: "",
        token: localStorage.getItem("logintoken"),
      },
      userparm: [], //搜索权限
      listData: [], //用户数据
      // 分页参数
      pageparm: {
        currentPage: 1,
        pageSize: 10,
        total: 10,
      },
    };
  },
  // 注册组件
  components: {
    Pagination,
  },
  /**
   * 数据发生改变
   */

  /**
   * 创建完毕
   */
  created() {
    this.getpatientlist();
  },

  /**
   * 里面的方法只有被调用才会执行
   */
  methods: {
    handleChange (value) {
        let data =CodeToText[value[0]]+"-"+CodeToText[value[1]]+"-"+CodeToText[value[2]];
        // this.editForm.address = data;
        this.editForm.address = data;
                    
      },
    getpatientlist() {
      this.formInline.rid=this.$route.query.registerId;
      console.log("this.formInline.rid-------------------",this.formInline.rid)
      this.patient.rid  = this.formInline.rid;
      this.patient.pageNum = this.formInline.page;
      this.patient.pageSize = this.formInline.limit;
      axios.post("/api/chargeManagement/select", this.patient).then((res) => {
        this.loading = false;
        this.listData = res.data.data.list;
        // 分页赋值
        this.pageparm.currentPage = this.formInline.page;
        this.pageparm.pageSize = this.formInline.limit;
        this.pageparm.total = res.data.data.total;
      });
    },
    // 分页插件事件
    callFather(parm) {
      this.formInline.page = parm.currentPage;
      this.formInline.limit = parm.pageSize;
      // this.getdata(this.formInline);
      this.getpatientlist();

    },
    // 搜索事件
    search() {
      this.formInline.page = 1;
      if(this.value2!==null&&this.value2!==""){
        this.patient.startDate = this.value2[0];
        this.patient.endDate = this.value2[1];
      }else{
        this.patient.startDate=null;
        this.patient.endDate=null;
      }
      this.patient.rid=this.formInline.rid;
      this.patient.pageNum = 1;
      this.patient.pageSize=100;
      // this.patient.keywords = this.formInline.name;
      axios.post("/api/chargeManagement/select", this.patient)
        .then((res) => {
          this.loading = false;
          // console.log('结果是',res)
          // listData赋值
          this.listData = res.data.data.list;
          // 分页赋值
          this.pageparm.currentPage = this.formInline.page;
          this.pageparm.pageSize = this.formInline.limit;
          this.pageparm.total = res.data.data.total;
        })
        .catch((err) => {
          // this.loading = false
          // this.$message.error('员工列表加载失败，请稍后再试！')
        });
    },
     // 跳转至收费详情页面
    //  rId,pId,pName,pAge,pSex
    handleEdit(){
      this.$router.push({
        path:"/statisticalreport/ChargeStatistics",
        query:{
          // patientId: pId,
          // registerId: rId,
          // patientName:pName,
          // patientAge:pAge,
          // patientSex:pSex
          }
      })
    },
    //显示编辑界面
    // handleEdit: function (index, row) {
    //   this.editFormVisible = true;
    //   if (row != undefined && row != "undefined") {
    //     //将地址分割
    //     var addrs = row.address.split("-")
    //     //转换为地址编码数组
    //     let addrNo=[];
    //     addrNo[0] = TextToCode[addrs[0]].code;
    //     addrNo[1] = TextToCode[addrs[0]][addrs[1]].code;
    //     addrNo[2] = TextToCode[addrs[0]][addrs[1]][addrs[2]].code;
    //     this.title = "修改";
    //     this.editForm.id = row.id;
    //     this.editForm.name = row.name;
    //     this.editForm.idcard = row.idcard;
    //     this.editForm.age = row.age;
    //     this.editForm.birthday = row.birthday;
    //     // console.log(row.birthday);
    //     this.editForm.sex = row.sex;
    //     this.editForm.phoneNumber = row.phoneNumber;
    //     this.editForm.myAddress = addrNo;
    //     this.editForm.detailAddress = row.detailAddress;
    //     this.editForm.source = row.source;
    //     this.editForm.nation = row.nation;
    //     this.editForm.maritalStatus = row.maritalStatus;
    //     this.editForm.education = row.education;
    //     this.editForm.occupation = row.occupation;
    //     this.editForm.workPlace = row.workPlace;
    //     this.editForm.mark = row.mark;
    //   } else {
    //     this.title = "添加";
    //     this.editForm.name = "";
    //     this.editForm.idcard = "";
    //     this.editForm.age = "";
    //     this.editForm.birthday = "";
    //     this.editForm.sex = "";
    //     this.editForm.phoneNumber = "";
    //     this.editForm.myAddress = "";
    //     this.editForm.detailAddress = "";
    //     this.editForm.source = "";
    //     this.editForm.nation = "";
    //     this.editForm.maritalStatus = "";
    //     this.editForm.education = "";
    //     this.editForm.occupation = "";
    //     this.editForm.workPlace = "";
    //     this.editForm.mark = "";
    //   }
    // },
    // 编辑、增加页面保存方法
    submitForm(editData) {
      this.$refs[editData].validate((valid) => {
        // console.log('editForm',this.editForm);
          //判断是新增还是 修改  发送不同的请求
          if (this.title=='添加') {
            if (valid) {
                //新增请求
              this.editForm.birthday.setDate(this.editForm.birthday.getDate()+1);
              axios .post("/api/patient/addOnePatient", this.editForm)
              .then((res) => {
              this.loading = false;
              if (res.data.code==200) {
                alert("新增成功!")
                this.getpatientlist();
              } else {
                alert("新增失败!")
              }
               this.editFormVisible = false;
            })
            .catch((err) => {
              this.editFormVisible = false;
              this.loading = false;
              alert("系统繁忙,稍后再试!")
            });
            }else{
              return false;
            }
            
          }else{
             //修改请求
             this.editForm.birthday.setDate(this.editForm.birthday.getDate()+1);
              axios .post("/api/patient/updateOneById", this.editForm)
              .then((res) => {
              // this.editFormVisible = false;
              this.loading = false;
              if (res.data.code==200) {
                alert("修改成功!")
                this.getpatientlist();
              } else {
                alert("修改失败!")
              }
              this.editFormVisible = false;
            })
            .catch((err) => {
              this.editFormVisible = false;
              this.loading = false;
              alert("系统繁忙,稍后再试!")
            });
          }
        
      });
    },
    // 删除患者
    deletePatient(index, row) {
      // console.log("index", index);
      // console.log("row", row.id);
      this.$confirm("确定要删除吗?", "信息", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          //发送请求 根据id删除 患者
          axios
            .post("/api/patient/deleteOne?id=" + row.id)
            .then((res) => {
              this.loading = false;
              console.log("删除的结果是", res);
              this.getpatientlist();
            })
            .catch((err) => {
              // this.loading = false
              // this.$message.error('员工列表加载失败，请稍后再试！')
              alert("删除失败,请联系管理员!");
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "取消删除",
          });
        });
    },
    // 关闭编辑、增加弹出框
    closeDialog(formName) {
      this.editFormVisible = false;
      this.$refs[formName].resetFields();
    },
  },
};
</script>

<style scoped>
.user-search {
  margin-top: 20px;
}
.userRole {
  width: 100%;
}
</style>

 
 